﻿using System;
using Domain.Engine.Events;
using SimpleCqrs.Eventing;

namespace Domain.Engine.Tests
{
  public class Game :
    IHandleDomainEvents<NewGameStartedEvent>
  {
    public Game()
    {
      Board = new Board();
    }

    public Board Board { get; set; }

    public void Handle(NewGameStartedEvent domainEvent)
    {
      var row0 = new[]
      {
        PieceType.Rook,
        PieceType.Knight,
        PieceType.Bishop,
        PieceType.Queen,
        PieceType.King,
        PieceType.Bishop,
        PieceType.Knight,
        PieceType.Rook
      };

      for (int col = 0; col < 8; col ++)
      {
        Board.Cells[0, col].Content = Piece.Create(row0[col], PieceColor.Black);
        Board.Cells[1, col].Content = Piece.Create(PieceType.Pawn, PieceColor.Black);
        Board.Cells[6, col].Content = Piece.Create(PieceType.Pawn, PieceColor.White);
        Board.Cells[7, col].Content = Piece.Create(row0[col], PieceColor.White);
      }
    }
  }
}